#include <iostream>
#include <vector>

struct point {
	point(const double x = 0, const double y = 0): x_(x), y_(y) {};

	double x() const {
		return x_;
	}

	double y() const {
		return y_;
	}

private:
	double x_, y_;
};

double squared(const double x) {
	return x * x;
}

double squared_distance(const point& a, const point& b) {
	return squared(a.x() - b.x()) + squared(a.y() - b.y());
}

typedef std::vector<point> vector;

using std::cin;
using std::cout;

int main(int argc, char* argv[]) {
	size_t n;
	cin >> n;
	vector s(n);

	double x, y;
	for (size_t i = 0; i < n; i++) {
		cin >> x >> y;
		s[i] = point(x, y);
	}

	cout.precision(100);

	size_t m;
	cin >> m;

	for (size_t i = 0; i < m; i++) {
		cin >> x >> y;
		point query(x, y);
		point answer = s[0];

		size_t size = s.size();
		for (size_t i = 1; i < size; i++) {
			point current = s[i];

			if (squared_distance(current, query) < squared_distance(answer, query)) {
				answer = current;
			}
		}

		cout << std::fixed << answer.x() << " " << answer.y() << "\n";
	}

	return 0;
}
